<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/static/css/public.css" media="all" />
</head>
<body class="childrenBody">
<div class="layui-container">
    <form class="layui-form layui-row layui-col-space10">
        <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md12 layui-col-xs7">
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">留言内容</label>
                        <div class="layui-input-block">
                            <textarea  class="layui-textarea mesContext" AUTOCOMPLETE="off" name="mesContext"  lay-verify="required" placeholder="请输入您想要留言的内容" ></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md12 layui-col-xs7">
                    <div class="layui-form-item magt3">
                        <!--医生号-->
                        <input type="hidden" class="doctorNo" name="doctorNo">
                        <div class="layui-input-block">
                            <a class="layui-btn layui-btn-sm" lay-filter="submitBtn" lay-submit><i class="layui-icon">&#xe606;</i>提交</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
</body>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script>
    layui.use(['form','jquery'],function () {
        var form = layui.form,
            $ = layui.jquery;
        form.on('submit(submitBtn)',function (obj) {
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            var data = obj.field;
            console.log(data);
            /**
             * 请求后台
             */
            $.ajax({
                type:'POST',
                url:'/message/addMessage',
                data:JSON.stringify(data),
                dataType:'json',
                contentType:'application/json',
                success:function (res) {
                    /**
                     * 添加成功后回调
                     **/
                    setTimeout(function(){
                        top.layer.close(index);
                        top.layer.msg("留言成功！");
                        layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                    },500);
                    return false;
                }
            });
        })
    });



</script>